from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.orm import sessionmaker

Base = declarative_base()

mysql_engine_str = "mysql+pymysql://novel:novel@localhost:3306/novel"

# engine = create_engine(mysql_engine_str, echo=True)
engine = create_engine(mysql_engine_str, echo=False)

Session = sessionmaker(bind=engine)
session = Session()


def get_session():
    return session


class Novel(Base):
    __tablename__ = 'novel'

    id = Column(Integer, primary_key=True)
    website_url = Column(String(255))
    novel_url = Column(String(255))
    novel_name = Column(String(50))
    novel_cover_url = Column(String(255))
    novel_desc = Column(String(255))
    novel_author = Column(String(50))
    novel_lasted_update = Column(DateTime)
    novel_lasted_chapter_name = Column(String(255))
    novel_lasted_chapter_url = Column(String(255))
